//
// Created by zhouwd on 2019/7/15.
//

#include "media_player.h"


int _MEDIA_PLAYER::init(const char *path, const char *mPreviewVertexShaderBuffer, const char *mPreviewFragmentShaderBuffer) {
    mediaExtractor = new MediaExtractor();
    mediaExtractor->init(path);

    int videoWidth = mediaExtractor->getVideoWidth();
    int videoHeight = mediaExtractor->getVideoHeight();
    ALOGE("_MEDIA_PLAYER > init > videoWidth > %d > videoHeight > %d", videoWidth, videoHeight);
    mediaRender = new MediaRender();
    mediaExtractor->initMediaRender(mediaRender);
    mediaRender->init(videoWidth, videoHeight, mPreviewVertexShaderBuffer, mPreviewFragmentShaderBuffer);



    return 0;
}

int _MEDIA_PLAYER::start() {

    mediaExtractor->startExtractor();
    return 0;
}

int _MEDIA_PLAYER::pause() {


    return 0;
}

int _MEDIA_PLAYER::stop() {


    return 0;
}

int _MEDIA_PLAYER::release() {
    mediaExtractor->destroy();
    delete mediaExtractor;

    mediaRender->destory();
    delete mediaRender;

    return 0;
}

int _MEDIA_PLAYER::step() {

    return mediaRender->step();
}

int _MEDIA_PLAYER::resize() {

    return mediaRender->resize();
}

int _MEDIA_PLAYER::setMediaVideoFrameNotify(MediaVideoFrameNotify *mediaVideoFrameNotify) {

    return mediaRender->setMediaVideoFrameNotify(mediaVideoFrameNotify);
}

int _MEDIA_PLAYER::setMediaInitNotify(MediaInitNotify *mediaInitNotify) {

    this->mediaInitNotify = mediaInitNotify;

    return 0;
}

int _MEDIA_PLAYER::setMediaAudioFrameNotify(MediaAudioFrameNotify *mediaAudioFrameNotify) {



    return 0;
}


